<template>
  <div>
    {{pic}}
    <h1>图片上传</h1>
    <van-uploader :after-read="upload"/>
  </div>
</template>

<script>
export default {
  name: "cate",
  data(){
    return{
      token:'',
      pic:''
    }
  },
  methods:{
    upload(file){
      var formdate=new FormData()
      formdate.append('token',this.token)
      formdate.append('file',file.file)
      this.axios.post('http://up-z1.qiniu.com/',formdate).then(res=>{
        this.pic='http://.r33uftv1o.hb-bkt.clouddn.com/'+res.data.key
        alert('添加成功')
      })

    },
    gettoken(){
      this.axios.get('qntoken').then(res=>{
        this.token=res.data.token
      })
    }
  },
  mounted() {
    this.gettoken()
  }
}
</script>

<style scoped>

</style>
